<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - qgetopt test coverage - object/optionManager/optManager.h</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../index.html">directory</a> - <a href="index.html">object/optionManager</a> - optManager.h</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>qgetopt test coverage</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2009-08-26</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">13</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">100.0 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">13</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : /** \defgroup qgetopt
<span class="lineNum">       2 </span>                :   \brief A Qt library to manage command line arguments.
<span class="lineNum">       3 </span>                :   It will accept long options that start with a double hyphen and
<span class="lineNum">       4 </span>                :   optionally short options that will start with a single hyphen.
<span class="lineNum">       5 </span>                : 
<span class="lineNum">       6 </span>                :   Any option can have arguments passed to it.
<span class="lineNum">       7 </span>                :   The arguments can be optional signified by being in square brackets.
<span class="lineNum">       8 </span>                :   The program itself can also have options, these however would be compulsory.
<span class="lineNum">       9 </span>                : 
<span class="lineNum">      10 </span>                :   To use the library there are two stages,
<span class="lineNum">      11 </span>                :   first define the options that are permitted
<span class="lineNum">      12 </span>                :   then parse the options that have been passed in.
<span class="lineNum">      13 </span>                : 
<span class="lineNum">      14 </span>                :   There is always a default --help and -h switch that can be used to display the available switches.
<span class="lineNum">      15 </span>                : 
<span class="lineNum">      16 </span>                :   The following snippet illustrates how to define the permitted options.
<span class="lineNum">      17 </span>                :   \code
<span class="lineNum">      18 </span>                :    OptManager * om = OptManager::getOptMgr(argv[0]);
<span class="lineNum">      19 </span>                :    om-&gt;addAppArgs(&quot;FILE&quot;);
<span class="lineNum">      20 </span>                :    om-&gt;addSwitch(&quot;verbose&quot;,verbose, &quot;v&quot;, &quot;[LEVEL]&quot;);
<span class="lineNum">      21 </span>                :   \endcode
<span class="lineNum">      22 </span>                :   An instance of the OptManager class is returned by the static method OptManager::getOptMgr(),
<span class="lineNum">      23 </span>                :   which for the first time it is called expects to receive a QString with the name of the program.
<span class="lineNum">      24 </span>                : 
<span class="lineNum">      25 </span>                :   Program arguments can be added by the method OptManager::addAppArgs()
<span class="lineNum">      26 </span>                : 
<span class="lineNum">      27 </span>                :   A switch can be added by the method OptManager::addSwitch(), in the above instance the switch
<span class="lineNum">      28 </span>                :   is called verbose with a short option of v it has an optional argument LEVEL and if
<span class="lineNum">      29 </span>                :   it is used in teh program then it will call a function called verbose,
<span class="lineNum">      30 </span>                :   which may be defined as follows:
<span class="lineNum">      31 </span>                :   \code
<span class="lineNum">      32 </span>                :    int verboseLevel=0;
<span class="lineNum">      33 </span>                : 
<span class="lineNum">      34 </span>                :    void verbose(const OptSwitch * opt)
<span class="lineNum">      35 </span>                :    {
<span class="lineNum">      36 </span>                :       QString arg = opt-&gt;argList();
<span class="lineNum">      37 </span>                :       int level;
<span class="lineNum">      38 </span>                :       bool ok = true;
<span class="lineNum">      39 </span>                :       if (arg.isEmpty())
<span class="lineNum">      40 </span>                :          level = 1;
<span class="lineNum">      41 </span>                :       else
<span class="lineNum">      42 </span>                :          level = arg.toInt(&amp;ok,10);
<span class="lineNum">      43 </span>                :       if (!ok)
<span class="lineNum">      44 </span>                :          level = 1;
<span class="lineNum">      45 </span>                :       verboseLevel = level;
<span class="lineNum">      46 </span>                :    }
<span class="lineNum">      47 </span>                :   \endcode
<span class="lineNum">      48 </span>                : 
<span class="lineNum">      49 </span>                :   The following snippet illustrates how to define process the options passed in.
<span class="lineNum">      50 </span>                :   \code
<span class="lineNum">      51 </span>                :    OptManager * om = OptManager::getOptMgr();
<span class="lineNum">      52 </span>                :    om-&gt;parse(argc, argv);
<span class="lineNum">      53 </span>                :   \endcode
<span class="lineNum">      54 </span>                : 
<span class="lineNum">      55 </span>                :  * \attention This program is free software; you can redistribute it and/or modify
<span class="lineNum">      56 </span>                :  * it under the terms of the GNU General Public License as published by
<span class="lineNum">      57 </span>                :  * the Free Software Foundation; either version 2 of the License, or
<span class="lineNum">      58 </span>                :  * (at your option) any later version.
<span class="lineNum">      59 </span>                :  *
<span class="lineNum">      60 </span>                :  * \attention This program is distributed in the hope that it will be useful,
<span class="lineNum">      61 </span>                :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
<span class="lineNum">      62 </span>                :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
<span class="lineNum">      63 </span>                :  * GNU General Public License for more details.
<span class="lineNum">      64 </span>                :  *
<span class="lineNum">      65 </span>                :  * \attention You should have received a copy of the GNU General Public License
<span class="lineNum">      66 </span>                :  * along with this program; if not, write to the
<span class="lineNum">      67 </span>                :  * Free Software Foundation, Inc.,
<span class="lineNum">      68 </span>                :  * 59 Temple Place - Suite 330, Boston, MA  02111-1307  USA
<span class="lineNum">      69 </span>                :  *
<span class="lineNum">      70 </span>                :    \author    Graeme
<span class="lineNum">      71 </span>                :    \date Copyright (C) 2008-9  Graeme Foster
<span class="lineNum">      72 </span>                :  */
<span class="lineNum">      73 </span>                : #ifndef OPT_MANAGER_H
<span class="lineNum">      74 </span>                : #define OPT_MANAGER_H
<span class="lineNum">      75 </span>                : 
<span class="lineNum">      76 </span>                : #include &lt;QtCore&gt;
<span class="lineNum">      77 </span>                : 
<span class="lineNum">      78 </span>                : #include &quot;optArgument.h&quot;
<span class="lineNum">      79 </span>                : class OptSwitch;
<span class="lineNum">      80 </span>                : 
<span class="lineNum">      81 </span>                : /*! pointer to method that is used to initialise switch data */
<span class="lineNum">      82 </span>                : typedef void (* InitFuncPtr)(const QStringList&amp;);
<span class="lineNum">      83 </span>                : /*! pointer to method that is used to perform the action */
<span class="lineNum">      84 </span>                : typedef void (* ActionFuncPtr)(const OptSwitch*);
<span class="lineNum">      85 </span>                : /*! pointer to method that is used after the action has been performed */
<span class="lineNum">      86 </span>                : typedef void (* CloseFuncPtr)();
<span class="lineNum">      87 </span>                : #include &quot;optSwitch.h&quot;
<span class="lineNum">      88 </span>                : 
<span class="lineNum">      89 </span>                : /*! \ingroup qgetopt
<span class="lineNum">      90 </span>                :     \brief The OptManager class is a manager class for the options.
<span class="lineNum">      91 </span>                :            It has two main roles to record the possible options the program has
<span class="lineNum">      92 </span>                :            and then to determine which options the users has selected.
<span class="lineNum">      93 </span>                : 
<span class="lineNum">      94 </span>                :    &lt;h3&gt;Overview&lt;/h3&gt;
<span class="lineNum">      95 </span>                :    This is a singleton class, the constructor is private and the instance of the
<span class="lineNum">      96 </span>                :    class is obtained via the static method getOptMgr().
<span class="lineNum">      97 </span>                : 
<span class="lineNum">      98 </span>                :    A program may have two types of options; \em switches and \em arguments.
<span class="lineNum">      99 </span>                :    A \em switch can be described as a request for an action to happen and is managed by the OptSwitch class,
<span class="lineNum">     100 </span>                :    whilst an \em argument is data that is passed into the program and is managed by the OptArgument class.
<span class="lineNum">     101 </span>                :    A switch may also have arguments.
<span class="lineNum">     102 </span>                : 
<span class="lineNum">     103 </span>                :    A switch is preceded by a single minus sign and a single character (short switch),
<span class="lineNum">     104 </span>                :    or a double minus sign and then the descriptive name of the switch (long switch).
<span class="lineNum">     105 </span>                :    Short switches can be combined together. For example:
<span class="lineNum">     106 </span>                :    &lt;table&gt;
<span class="lineNum">     107 </span>                :    &lt;tr&gt;&lt;td&gt;-h&lt;/td&gt;&lt;td&gt;short switch&lt;/td&gt;&lt;/tr&gt;
<span class="lineNum">     108 </span>                :    &lt;tr&gt;&lt;td&gt;--help&lt;/td&gt;&lt;td&gt;long switch&lt;/td&gt;&lt;/tr&gt;
<span class="lineNum">     109 </span>                :    &lt;tr&gt;&lt;td&gt;-lvd&lt;/td&gt;&lt;td&gt;three short switches&lt;/td&gt;&lt;/tr&gt;
<span class="lineNum">     110 </span>                :    &lt;/table&gt;
<span class="lineNum">     111 </span>                : 
<span class="lineNum">     112 </span>                :    A switch argument will appear after the switch with a space separating them.
<span class="lineNum">     113 </span>                :    When a argument follows multiple short switches the argument is associated with the last switch.
<span class="lineNum">     114 </span>                :    Program arguments appear at the end of the list of options and are each separated by a space. For example:
<span class="lineNum">     115 </span>                :    &lt;table&gt;
<span class="lineNum">     116 </span>                :    &lt;tr&gt;&lt;td&gt;--log myprog.log&lt;/td&gt;&lt;td&gt;the argument &lt;em&gt;myprog.log&lt;/em&gt; is associated with the switch &lt;em&gt;--log&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;
<span class="lineNum">     117 </span>                :    &lt;tr&gt;&lt;td&gt;-vl myprog.log&lt;/td&gt;&lt;td&gt;the argument &lt;em&gt;myprog.log&lt;/em&gt; is associated with the switch &lt;em&gt;-l&lt;/em&gt; and not -v&lt;/td&gt;&lt;/tr&gt;
<span class="lineNum">     118 </span>                :    &lt;/table&gt;
<span class="lineNum">     119 </span>                : 
<span class="lineNum">     120 </span>                :    For a program all arguments are mandatory, whilst for a switch arguments can be optional.
<span class="lineNum">     121 </span>                :    &lt;em&gt;The reason that program arguments are mandatory is that it may not be possible to distinguish
<span class="lineNum">     122 </span>                :    between an optional program argument and an optional switch argument.&lt;/em&gt;
<span class="lineNum">     123 </span>                :    If it transpires that it is necessary for the program to have optional arguments this can be done, for example,
<span class="lineNum">     124 </span>                :    by adding a switch called --optionalArguments and listing them there.
<span class="lineNum">     125 </span>                :    This obviously will require the user to implement this switch.
<span class="lineNum">     126 </span>                : 
<span class="lineNum">     127 </span>                :    &lt;h3&gt;Usage&lt;/h3&gt;
<span class="lineNum">     128 </span>                :    ...Or how to use this class.
<span class="lineNum">     129 </span>                : 
<span class="lineNum">     130 </span>                :    The following example establishes a switch --verbose or just -v which has an optional LEVEL argument.
<span class="lineNum">     131 </span>                :    The program expects single argument to be passed in.
<span class="lineNum">     132 </span>                :    By default there will always be a --help or -h option.
<span class="lineNum">     133 </span>                :    If the verbose option is set from the command line then the function verbose() will be automatically called.
<span class="lineNum">     134 </span>                : 
<span class="lineNum">     135 </span>                :    \code
<span class="lineNum">     136 </span>                : #include &quot;optManager.h&quot;
<span class="lineNum">     137 </span>                : #include &lt;QtCore&gt;
<span class="lineNum">     138 </span>                : 
<span class="lineNum">     139 </span>                : void setOptions(QString ProgName);
<span class="lineNum">     140 </span>                : int verboseLevel=0;
<span class="lineNum">     141 </span>                : 
<span class="lineNum">     142 </span>                : void verbose(const OptSwitch * opt)
<span class="lineNum">     143 </span>                : {
<span class="lineNum">     144 </span>                :    QString arg = opt-&gt;argList();
<span class="lineNum">     145 </span>                :    int level;
<span class="lineNum">     146 </span>                :    bool ok = true;
<span class="lineNum">     147 </span>                :    if (arg.isEmpty())
<span class="lineNum">     148 </span>                :       level = 1;
<span class="lineNum">     149 </span>                :    else
<span class="lineNum">     150 </span>                :       level = arg.toInt(&amp;ok,10);
<span class="lineNum">     151 </span>                :    if (!ok)
<span class="lineNum">     152 </span>                :       level = 1;
<span class="lineNum">     153 </span>                :    verboseLevel = level;
<span class="lineNum">     154 </span>                : }
<span class="lineNum">     155 </span>                : 
<span class="lineNum">     156 </span>                : int main(int argc, char *argv[])
<span class="lineNum">     157 </span>                : {
<span class="lineNum">     158 </span>                :    setOptions(argv[0]);
<span class="lineNum">     159 </span>                :    OptManager * om = OptManager::getOptMgr();
<span class="lineNum">     160 </span>                :    om-&gt;parse(argc, argv);
<span class="lineNum">     161 </span>                : 
<span class="lineNum">     162 </span>                :    QTextStream console(stdout);
<span class="lineNum">     163 </span>                :    console &lt;&lt; &quot;Verbose level set to \&quot;&quot; &lt;&lt; verboseLevel &lt;&lt;&quot;\&quot;\n&quot;;
<span class="lineNum">     164 </span>                : 
<span class="lineNum">     165 </span>                :    om-&gt;close();
<span class="lineNum">     166 </span>                :    return 0;
<span class="lineNum">     167 </span>                : }
<span class="lineNum">     168 </span>                : 
<span class="lineNum">     169 </span>                : void setOptions(QString ProgName)
<span class="lineNum">     170 </span>                : {
<span class="lineNum">     171 </span>                :    OptManager * om = OptManager::getOptMgr(ProgName);
<span class="lineNum">     172 </span>                :    om-&gt;addAppArgs(&quot;FILE&quot;);
<span class="lineNum">     173 </span>                :    om-&gt;addSwitch(&quot;verbose&quot;,verbose, &quot;v&quot;, &quot;[LEVEL]&quot;);
<span class="lineNum">     174 </span>                : }
<span class="lineNum">     175 </span>                : \endcode
<span class="lineNum">     176 </span>                :    &lt;h3&gt;Internals&lt;/h3&gt;
<span class="lineNum">     177 </span>                :    ...Or how does this class work?
<span class="lineNum">     178 </span>                : 
<span class="lineNum">     179 </span>                :    As already discussed, there are two phases namely, to record the possible options the application has
<span class="lineNum">     180 </span>                :    and then to determine which options the users has selected. Each of these will now be discussed in detail:
<span class="lineNum">     181 </span>                : 
<span class="lineNum">     182 </span>                :    &lt;h4&gt;Record an applications potential options&lt;/h4&gt;
<span class="lineNum">     183 </span>                :    When the OptManager instance is created the appName is passed in and the appName and path details are extracted by the
<span class="lineNum">     184 </span>                :    constructor.
<span class="lineNum">     185 </span>                :    General details about the application can be added by calling the addDescription() method.
<span class="lineNum">     186 </span>                :    A switch can be added by using the addSwitch() method. This method returns a pointer to the OptSwitch class
<span class="lineNum">     187 </span>                :    and so this pointer can be used to add a description to the switch by using the OptSwitch::addDescription() method.
<span class="lineNum">     188 </span>                :    Any application specific methods that are required to be run before any switches should be wrapped in a method
<span class="lineNum">     189 </span>                :    and set up by calling addInitMethod().
<span class="lineNum">     190 </span>                :    &lt;h4&gt;Determine the options a user has selected&lt;/h4&gt;
<span class="lineNum">     191 </span>                :    Typically there are two methods that need to be added to the applicaiton parse() and then close()
<span class="lineNum">     192 </span>                :    any application specific code that needs to be run should appear between these two method calls.
<span class="lineNum">     193 </span>                :    &lt;h5&gt;The anatomny of parse()&lt;/h5&gt;
<span class="lineNum">     194 </span>                :    The parse() method is key to the functionality of this library. The method steps through each argument
<span class="lineNum">     195 </span>                :    that has been passed into the application, and determines if it is a switch or an argument to either a switch or the application,
<span class="lineNum">     196 </span>                :    (remember all switches start with a special character to distinguish them from an argument).
<span class="lineNum">     197 </span>                :    Once this method has stepped through all the arguments that have been passed in it will have two lists:
<span class="lineNum">     198 </span>                :    * A list of switches that have been selected (activeSwitches)
<span class="lineNum">     199 </span>                :    * A list of arguments to the application (actualAppArgList)
<span class="lineNum">     200 </span>                :    Then the execute method will be called, it will loop through each of the entries in the activeSwitches and if it finds
<span class="lineNum">     201 </span>                :    any with the finishProcessing flag set to true it will run this method and the exit the application.
<span class="lineNum">     202 </span>                :    Next it will run any initMethod passing it the list of arguments to the application.
<span class="lineNum">     203 </span>                :    Finally it will loop through each of the entries in the activeSwitches and run their code.
<span class="lineNum">     204 </span>                : */
<span class="lineNum">     205 </span>                :  /*! \todo Add a automatic switch --clopts FILE that will read a file of command line options
<span class="lineNum">     206 </span>                :      \todo Change parseArgument() so that if the last switch is in error it will remove it from activeSwitches
<span class="lineNum">     207 </span>                :      \todo Add an execute function for the app to be executed before any non conclude methods
<span class="lineNum">     208 </span>                :  */
<span class="lineNum">     209 </span>                : class OptManager
<span class="lineNum">     210 </span><span class="lineCov">              4 : {</span>
<span class="lineNum">     211 </span>                :    private:
<span class="lineNum">     212 </span>                :       //! \internal Pointer to the instance of this class
<span class="lineNum">     213 </span>                :       static OptManager * _instancePtr;
<span class="lineNum">     214 </span>                : 
<span class="lineNum">     215 </span>                :    public:
<span class="lineNum">     216 </span>                :       //! Method to return the instance of this class
<span class="lineNum">     217 </span>                :       static OptManager * getOptMgr(QString appFullName=&quot;&quot;);
<span class="lineNum">     218 </span>                : 
<span class="lineNum">     219 </span>                :       //! Method to delete the instance
<span class="lineNum">     220 </span><span class="lineCov">              4 :       static void clear(){delete _instancePtr;_instancePtr=0;}</span>
<span class="lineNum">     221 </span>                : 
<span class="lineNum">     222 </span>                :       //! Method to display the help screen
<span class="lineNum">     223 </span>                :       /*!
<span class="lineNum">     224 </span>                :           This will display brief details on how to use the program. The details
<span class="lineNum">     225 </span>                :           are obtained from the descriptions that have been added along with the
<span class="lineNum">     226 </span>                :           switches that have been defined.
<span class="lineNum">     227 </span>                :        */
<span class="lineNum">     228 </span><span class="lineCov">              2 :       static void help(const OptSwitch*)</span>
<span class="lineNum">     229 </span>                :       {
<span class="lineNum">     230 </span><span class="lineCov">              2 :          QTextStream console(stdout);</span>
<span class="lineNum">     231 </span><span class="lineCov">              2 :          console &lt;&lt; getOptMgr()-&gt;pHelp();</span>
<span class="lineNum">     232 </span><span class="lineCov">              2 :          console.flush();</span>
<span class="lineNum">     233 </span><span class="lineCov">              2 :       }</span>
<span class="lineNum">     234 </span>                : 
<span class="lineNum">     235 </span>                :    private:
<span class="lineNum">     236 </span>                :       //! \internal The name of the application
<span class="lineNum">     237 </span>                :       QString _appName;
<span class="lineNum">     238 </span>                :       //! \internal The path to the application
<span class="lineNum">     239 </span>                :       QString _path;
<span class="lineNum">     240 </span>                :       //! \internal The list of command line arguments passed in
<span class="lineNum">     241 </span>                :       QString _cmdLine;
<span class="lineNum">     242 </span>                :       //! \internal A description of the application
<span class="lineNum">     243 </span>                :       QString _description;
<span class="lineNum">     244 </span>                :       //! \internal The initialisation method
<span class="lineNum">     245 </span>                :       InitFuncPtr _initMethodPtr;
<span class="lineNum">     246 </span>                :       //! \internal The list of switches that the application will accept
<span class="lineNum">     247 </span>                :       QList &lt;OptSwitch *&gt; _switchList;
<span class="lineNum">     248 </span>                :       //! \internal The list of switches that the application has received
<span class="lineNum">     249 </span>                :       QList&lt;OptSwitch *&gt; _activeSwitches;
<span class="lineNum">     250 </span>                :       //! \internal The list of arguments that the application will expect
<span class="lineNum">     251 </span>                :       QList &lt;OptArgument *&gt; _argList;
<span class="lineNum">     252 </span>                :       //! \internal The application arguments that have actually been passed in
<span class="lineNum">     253 </span>                :       QStringList _actualAppArgList;
<span class="lineNum">     254 </span>                :       //! \internal A list of warning messages that have been raised
<span class="lineNum">     255 </span>                :       QStringList _warning;
<span class="lineNum">     256 </span>                :       //! \internal A list of error messages that have been raised
<span class="lineNum">     257 </span>                :       QStringList _error;
<span class="lineNum">     258 </span>                :    private:
<span class="lineNum">     259 </span>                :       //! \internal Private constructor for singleton class
<span class="lineNum">     260 </span>                :       OptManager(QFileInfo appFullName);
<span class="lineNum">     261 </span>                :       //! \internal Private copy constructor for singleton class
<span class="lineNum">     262 </span>                :       /*! \internal This should not be called so an exception is thrown */
<span class="lineNum">     263 </span>                :       OptManager(const OptManager&amp;){throw &quot;OptManager copy constructor called&quot;;}
<span class="lineNum">     264 </span>                :       //! \internal return true if \em param is a recognised switch
<span class="lineNum">     265 </span>                :       bool isSwitch(QString param);
<span class="lineNum">     266 </span>                :       //! \internal return true if \em param is a recognised short switch
<span class="lineNum">     267 </span>                :       bool isShortSwitch(QString param);
<span class="lineNum">     268 </span>                :       //! \internal return true if \em param is a recognised long switch
<span class="lineNum">     269 </span>                :       bool isLongSwitch(QString param);
<span class="lineNum">     270 </span>                :       //! \internal return true if \em param is a number
<span class="lineNum">     271 </span>                :       bool isNumber(QString param);
<span class="lineNum">     272 </span>                :       //! \internal return true if the short switch is unique
<span class="lineNum">     273 </span>                :       bool uniqueAbbrev(QChar abbrev);
<span class="lineNum">     274 </span>                :       //! \internal return an instance of OptSwitch from \em opt which has been passed in
<span class="lineNum">     275 </span>                :       OptSwitch * parseSwitch(QString opt);
<span class="lineNum">     276 </span>                :       //! \internal return an instance of OptSwitch from \em opt which has been passed in
<span class="lineNum">     277 </span>                :       OptSwitch * parseShortSwitchList(QString opt);
<span class="lineNum">     278 </span>                :       //! \internal return an instance of OptSwitch from \em opt which has been passed in
<span class="lineNum">     279 </span>                :       OptSwitch * parseShortSwitch(QChar opt);
<span class="lineNum">     280 </span>                :       //! \internal return an instance of OptSwitch from \em opt which has been passed in
<span class="lineNum">     281 </span>                :       OptSwitch * parseLongSwitch(QString opt);
<span class="lineNum">     282 </span>                :       //! \internal Sets up the arguments for the program or for a switch
<span class="lineNum">     283 </span>                :       bool parseArgument(OptSwitch * sw, QStringList &amp;argQueue, bool more);
<span class="lineNum">     284 </span>                :       //! \internal Sets up the arguments for a switch
<span class="lineNum">     285 </span>                :       bool parseSwitchArgument(OptSwitch * sw, QStringList &amp;argQueue);
<span class="lineNum">     286 </span>                :       //! \internal Method to ensure that the appropriate execute methods are called for each switch
<span class="lineNum">     287 </span>                :       void execute();
<span class="lineNum">     288 </span>                : 
<span class="lineNum">     289 </span>                :       //! \internal Display the help screen.
<span class="lineNum">     290 </span>                :       QString pHelp();
<span class="lineNum">     291 </span>                :    public:
<span class="lineNum">     292 </span>                :       //! Method to return the name of the application
<span class="lineNum">     293 </span><span class="lineCov">              1 :       QString getAppName(){return _appName;}</span>
<span class="lineNum">     294 </span>                :       //! Method to return the description associated with the application
<span class="lineNum">     295 </span><span class="lineCov">              1 :       QString getAppDesc(){return _description;}</span>
<span class="lineNum">     296 </span>                :       //! Method to return the value for a specific argument passed into the application
<span class="lineNum">     297 </span>                :       /*! This method will return the &lt;em&gt;i&lt;/em&gt;&lt;sup&gt;th&lt;/sup&gt; argument.
<span class="lineNum">     298 </span>                :           If there is no &lt;em&gt;i&lt;/em&gt;&lt;sup&gt;th&lt;/sup&gt; argument then blank is returned. */
<span class="lineNum">     299 </span><span class="lineCov">              6 :       QString getAppArg(int i){return ((i&gt;=0) &amp;&amp; (i&lt;_actualAppArgList.size()))? _actualAppArgList[i]:&quot;&quot;;}</span>
<span class="lineNum">     300 </span>                :       //! Method will return the arguments provided for a given switch
<span class="lineNum">     301 </span>                :       QStringList getSwitchDetails(QString opt);
<span class="lineNum">     302 </span>                :       //! Method to record the description of the program
<span class="lineNum">     303 </span>                :       /*! This method will add \em detail as a description of the program.
<span class="lineNum">     304 </span>                :           This description is used by the automatic --help switch. */
<span class="lineNum">     305 </span><span class="lineCov">             24 :       void addDescription(QString detail){_description=detail;}</span>
<span class="lineNum">     306 </span>                :       //! Method to add details about the arguments for the application
<span class="lineNum">     307 </span>                :       void addAppArgs (QString args);
<span class="lineNum">     308 </span>                :       //! Method to return details about a selected application argument
<span class="lineNum">     309 </span><span class="lineCov">              5 :       QString getAppArgTemplate (int i){return ((i&gt;=0) &amp;&amp; (i&lt;_argList.size()))? _argList[i]-&gt;help():&quot;&quot;;}</span>
<span class="lineNum">     310 </span>                :       //! Method to return details for a selected switch
<span class="lineNum">     311 </span>                :       QString switchDumpTemplate(int i);
<span class="lineNum">     312 </span>                :       //! Method to add a method that should be run before any other methods
<span class="lineNum">     313 </span>                :       /*! This method set up a initialisation method for the program which will receive
<span class="lineNum">     314 </span>                :           the program arguments. This means that an object can be set up before the methods
<span class="lineNum">     315 </span>                :           for the other switchesis run.
<span class="lineNum">     316 </span>                : 
<span class="lineNum">     317 </span>                :           Any switch that has the conclude flag set to true will be run first and so
<span class="lineNum">     318 </span>                :           in this specific case the initMethod will not be run. */
<span class="lineNum">     319 </span><span class="lineCov">              1 :       void addInitMethod(InitFuncPtr initMethod){_initMethodPtr=initMethod;}</span>
<span class="lineNum">     320 </span>                :       //! Method to add a switch to the program
<span class="lineNum">     321 </span>                :       OptSwitch * addSwitch(QString longName
<span class="lineNum">     322 </span>                :                             ,ActionFuncPtr actionMethod
<span class="lineNum">     323 </span>                :                             ,QChar abbrev=QChar::Null
<span class="lineNum">     324 </span>                :                             ,QString args=&quot;&quot;
<span class="lineNum">     325 </span>                :                             ,CloseFuncPtr exitMethod=0
<span class="lineNum">     326 </span>                :                             ,switchStyle style=continueRunning
<span class="lineNum">     327 </span>                :                             );
<span class="lineNum">     328 </span>                : 
<span class="lineNum">     329 </span>                :       //! Method to parse the command line arguments
<span class="lineNum">     330 </span>                :       QString parse(int argc, char *argv[], bool quiet=false);
<span class="lineNum">     331 </span>                :       //! Method should always be called when the program finishes
<span class="lineNum">     332 </span>                :       void close();
<span class="lineNum">     333 </span>                :       //! Method to return the errors
<span class="lineNum">     334 </span>                :       QString getErrors();
<span class="lineNum">     335 </span>                :       //! Method to return the warnings
<span class="lineNum">     336 </span>                :       QString getWarnings();
<span class="lineNum">     337 </span>                :       //! Method to return the switches that have been selected
<span class="lineNum">     338 </span>                :       QString switchDump();
<span class="lineNum">     339 </span>                :       //! Method to return the program arguments that have been provided
<span class="lineNum">     340 </span>                :       QString appArgDump();
<span class="lineNum">     341 </span>                :       //! Method to return both the switches and program arguments
<span class="lineNum">     342 </span>                :       QString dump(){return _appName + appArgDump() + &quot;\n&quot; + switchDump() + &quot;\n&quot;;}
<span class="lineNum">     343 </span>                : };
<span class="lineNum">     344 </span>                : 
<span class="lineNum">     345 </span>                : #endif
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
